#include "meaningoflife.h"
#include "ui_meaningoflife.h"
#include <QPainter>
#include <QFont>
#include <QPixmap>
#include <QTimer>

int i4=1;

meaningoflife::meaningoflife(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::meaningoflife)
{
    ui->setupUi(this);
}

void meaningoflife::paintEvent(QPaintEvent *)
{
    QPainter painter(this);
    painter.setPen(Qt::black);//设置画笔颜色
    painter.setBrush(Qt::black);//设置填充颜色
    painter.drawRect(0,0,480,480);
    int x1=ui->qhframe->pos().x();
    int y1=ui->qhframe->pos().y();
    qh[0].load(":/resourse/0.png") ;
    qh[1].load(":/resourse/1.png") ;
    qh[2].load(":/resourse/2.png") ;
    qh[3].load(":/resourse/3.png") ;
    qh[4].load(":/resourse/4.png") ;
    qh[5].load(":/resourse/5.png") ;
    qh[6].load(":/resourse/6.png") ;
    qh[7].load(":/resourse/7.png") ;
    qh[8].load(":/resourse/8.png") ;
    qh[9].load(":/resourse/9.png") ;
    qh[10].load(":/resourse/10.png") ;
    qh[12].load(":/resourse/12.png") ;
    qh[13].load(":/resourse/13.png") ;
    qh[14].load(":/resourse/14.png") ;
    qh[15].load(":/resourse/15.png") ;
    qh[16].load(":/resourse/16.png") ;
    qh[17].load(":/resourse/17.png") ;
    qh[18].load(":/resourse/18.png") ;
    qh[19].load(":/resourse/19.png") ;
    qh[20].load(":/resourse/20.png") ;
    qh[21].load(":/resourse/21.png") ;
    qh[22].load(":/resourse/22.png") ;
    qh[23].load(":/resourse/23.png") ;
    qh[24].load(":/resourse/24.png") ;
    qh[25].load(":/resourse/25.png") ;
    QFont font1("Courier New",10);
    painter.setFont(font1);
    painter.setPen(Qt::red);
    painter.setBrush(Qt::red);
    painter.drawText(10,185,dialog[i4]);

    if (i4==1||i4==2)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[1]);
    }
    if (i4==3||i4==4)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[12]);
    }
    if (i4==5||i4==6)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[1]);
    }
    if (i4==7)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[13]);
    }
    if (i4==8)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[17]);
    }
    if (i4==9)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[18]);
    }
    if (i4==10)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[10]);
    }
    if (i4==11)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[13]);
    }
    if (i4==12)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[1]);
    }
    if (i4==13)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[19]);
    }
    if (i4==14)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[7]);
    }
    if (i4==15)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[9]);
    }
    if (i4==16)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[6]);
    }
    if (i4==17)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[19]);
    }
    if (i4==18)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[8]);
    }
    if (i4==19)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[7]);
    }
    if (i4==20)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[8]);
    }
    if (i4==21)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[19]);
    }
    if (i4==22)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[9]);
    }
    if (i4==23)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[19]);
    }
    if (i4==24)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[1]);
    }
    if (i4==25)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[5]);
    }
    if (i4==26)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[7]);
    }
    if (i4==27)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[10]);
    }
    if (i4==28)
    {
        painter.drawPixmap(x1,y1,ui->qhframe->width(),ui->qhframe->height(),qh[1]);
    }

    if (i4==29)
    {
        this->close();
        Game4 *g4 =new Game4();
        g4->show();
    }

}

void meaningoflife::on_nextpushButton_clicked()
{
    i4++;
    update();
}


meaningoflife::~meaningoflife()
{
    delete ui;
}
